package net.youdi.gateway.properties;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import net.youdi.gateway.util.GateWayUtil;
import org.springframework.boot.context.properties.ConfigurationProperties;

@Slf4j
@Data
@ConfigurationProperties(GatewayProperties.GATEWAY_PLUGIN_PROPERTIES_PREFIX)
public class GatewayProperties {

    public static final String GATEWAY_PLUGIN_PROPERTIES_PREFIX = "spring.cloud.gateway.plugin.config";

    public static final String START_TIME = "startTime";

    public static final String USER_KEY = "USER_KEY";
    /**
     * Enable Or Disable 解密请求数据
     */
    private boolean decryptRequest = false;
    /**
     * Enable Or Disable 加密响应数据
     */
    private boolean encryptResponse = false;
    /**
     * Enable Or Disable Log Request Detail
     */
    private Boolean logRequest = true;

    private Boolean logResponse = true;
    /**
     * Enable Or Disable Global Exception Json Handler
     */
    private Boolean exceptionJsonHandler = false;

    private Boolean logCache = true;

    private AuthenticationProperties authentication = new AuthenticationProperties();

    private String[] noSensitiveUrls;

    public boolean isNoSensitive(String url){
        return GateWayUtil.match(url,noSensitiveUrls);
    }
}
